package cn.cmvideo.springboot.algorithm;

public class HanoiTower
{
	private final static String from = "柱子A";
	private final static String mid = "柱子B";
	private final static String to = "柱子C";

	/**
	 * 汉诺塔<br>
	 * func:<br>
	 * if n!=0 then ;预定值<br>
	 * func(n-1, a, c, b) ;将n-1个盘子由a移动到b，以c为辅助柱子（注意参数顺序）<br>
	 * move a[n] to c ;将a上的最后一个盘子移动到c<br>
	 * func(n-1, b, a, c) ;将n-1个盘子由b移动到c，以a为辅助柱子<br>
	 * endif ;完成<br>
	 * 
	 * @param n
	 * @param from2
	 * @param mid2
	 * @param to2
	 */
	public static void move(int n, String from2, String mid2, String to2)
	{
		if (n == 1)
		{
			System.out.println("移动盘子 " + n + " 从 " + from2 + " 到 " + to2);
		} else
		{
			move(n - 1, from2, to2, mid2);
			System.out.println("移动盘子 " + n + " 从 " + from2 + " 到 " + to2);
			move(n - 1, mid2, from2, to2);
		}
	}
	
	public static void main(String[] args)
	{
		move(3, from, mid, to);
//		Math.max
	}
}
